package com.tfswx.fljdmxyy.api;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.tfswx.fljdmxyy.dto.pzgl.*;
import com.tfswx.fljdmxyy.query.pzgl.PzxlbQueryParam;
import com.tfswx.fljdmxyy.query.pzgl.PzxlbQueryResult;
import com.tfswx.fljdmxyy.service.PzglService;
import com.tfswx.newbie.boot.starter.page.PageParam;
import com.tfswx.newbie.boot.starter.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 配置管理
 *
 * @Author 陈文佳
 * @Date 2023/03/24
 */
@RestController
@Api(tags = "配置管理")
@ApiSupport(order = 60)
@RequestMapping("api/pzgl")
public class PzglController {

    @Resource
    private PzglService pzglService;

    @ApiOperation("获取配置项")
    @ApiOperationSupport(order = 10)
    @PostMapping("getPzx")
    public PzxGetOutputDTO getPzx(@RequestBody @Validated PzxGetInputDTO dto) {
        return pzglService.getPzx(dto);
    }

    @ApiOperation("新增系统配置项")
    @ApiOperationSupport(order = 20)
    @PostMapping("addPzx")
    public PzxAddOutputDTO addPzx(@RequestBody @Validated PzxAddInputDTO dto) {
        return pzglService.addPzx(dto);
    }

    @ApiOperation("修改系统配置项")
    @ApiOperationSupport(order = 30)
    @PostMapping("updatePzx")
    public Boolean updatePzx(@RequestBody @Validated PzxUpdateInputDTO dto) {
        return pzglService.updatePzx(dto);
    }

    @ApiOperation("删除系统配置项")
    @ApiOperationSupport(order = 40)
    @PostMapping("deletePzx")
    public Boolean deletePzx(@RequestBody @Validated PzxDeleteInputDTO dto) {
        return pzglService.deletePzx(dto);
    }

    @ApiOperation("查询配置项列表")
    @ApiOperationSupport(order = 50)
    @PostMapping("queryPzxlb")
    public PageResult<PzxlbQueryResult> queryPzxlb(@RequestBody @Validated PageParam<PzxlbQueryParam> param) {
        return pzglService.queryPzxlb(param);
    }

    @ApiOperation("查询开放配置项列表")
    @ApiOperationSupport(order = 60)
    @PostMapping("queryKfpzx")
    public List<PzxlbQueryResult> queryKfpzx() {
        return pzglService.queryKfpzx();
    }
}
